<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>大耳狐 - 用户中心</title>
<link href="__PUBLIC__/css/client_common.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/css/user.css" rel="stylesheet" type="text/css" />

<script src="__PUBLIC__/js/jquery-1.7.2.js" type="text/javascript"></script>

<!-- dialog -->
<script type="text/javascript" src="__PUBLIC__/dialog/ymPrompt.js"></script>
<link rel="stylesheet" id='skin' type="text/css" href="__PUBLIC__/dialog/skin/dmm-green/ymPrompt.css" />

</head>
<body>
{:R('Public/Head','','Widget')}

<div id="content">
	 {:R('Public/MainHead','','Widget')}
	 
	 <div class="contentBox">
		<div id="leftMenu" class="leftPart6">
			{:R('Public/myShopMenu','','Widget')}
		</div>
		
		<div class="rightPart6">
			<div style="width:100%;border:1px dotted #ccc;padding:5px;">
				<div>
					<span style="font-size:12px;">产品类别：</span><span id="add_category_type" style="border:1px solid #ccc;padding:0 5px;cursor:pointer;">+</span>
				</div>
				<div>
					<table>
						<volist name="parentCategory" id="vo">
						<tr>
							<th style="font-size:12px;color:red;text-align:left;">
								<span style="font-size:12px;margin-right:10px;font-weight:bold;">{$vo.par.name}</span>
							</th>
							<td>
								<volist name="vo['sub']" id="val">
								<span style="font-size:12px;margin-right:5px;">{$val.name}</span>
								</volist>
							</td>
						</tr>
						</volist>
					</table>
				</div>
			</div>
			<div style="width:100%;margin-top:10px;border:1px dotted #ccc;padding:5px;">
				<span style="font-size:12px;">产品列表：</span>
				<span id="add_product" style="border:1px solid #ccc;padding:0 5px;cursor:pointer;">+</span>
				<span id="unadd_product" style="border:1px solid #ccc;padding:0 5px;cursor:pointer;display:none;">-</span>
				<div id="product_add" style="display:none;">
				</div>	
				<div id="product_list">
				产品列表
				</div>
			</div>
		</div>
		
		<div class="clear_both"></div>
	</div>
</div>

<script>
var plist = '{$plist}';

//添加产品类别

$("#add_category_type").click(function(){
	ymPrompt.win({
		title:'添加产品类别',width:360,height:180,fixPosition:true,
		btn:[['添加','yes'],['取消','cancel']],
		message:'<div style="padding:10px;">'
				+plist
				+'<div style="margin:7px 10px;">类别名称:<input type="text" name="name" id="pname" size="20"/></div>'
				+'</div>',
		handler:callback,
	});
});

var shopId = {$shopId};

function callback(tp){
	if (tp=='yes') {
		var pid = $("#p_id option:selected").val();
		var pname = $("#pname").val().trim();
	
		$.post(
			"__APP__/Shop/addProductCategory",
			{pid:pid, name:pname, shopId:shopId},
			function(result){
				var data = $.parseJSON(result);
				if (data.ret) {
					window.location.reload();
				} else {
					ymPrompt.alert({'title':'提示信息','message':data.msg});
				}
			}
		);
	}
	if (tp=='cancel') {
		ymPrompt.close();
	}
}


$("#add_product").click(function(){
	$(this).hide();
	$("#unadd_product").show();
	
	$.post(
		'__APP__/Shop/addProduct',
		{shopId:shopId},
		function (data) {
			$("#product_add").html(data).show();
			$("#product_list").hide();
		}
	);
});

function unadd(){
	$("#product_add").hide();
	$("#product_list").show();
	$("#add_product").show();
	$("#unadd_product").hide();
}

$("#unadd_product").click(function(){
	unadd();
});

</script>

{:R('Public/Footer','','Widget')}